import QtQuick


Rectangle {
    id: button
    property bool hovered: false
    property bool plain: false
    property string text: ""

    // 定义一个信号
    signal buttonClicked()

    width: 60
    height: 30
    border.color: "#ee6600"
    opacity:hovered?0.9:1
    color: plain?"#ffffff":"#ee6600"
    radius:2

    Text {
        font.pixelSize: 12
        verticalAlignment: Text.AlignVCenter  // 垂直居中
        horizontalAlignment: Text.AlignHCenter  // 水平居中
        anchors.fill: parent  // 填充父组件
        text: button.text
        color: plain?"#ee6600":"#ffffff"
        focus: false
    }
    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        cursorShape: Qt.PointingHandCursor

        onEntered: {
            hovered = true
        }

        onExited: {
            hovered = false
        }
        onPressed: {
            hovered = false
        }
        onReleased: {
            hovered = true
            buttonClicked()
        }
    }
}


